package com.hkts.reportform.config;

import com.hkts.reportform.datastatics.service.GreenBodiesService;
import com.hkts.reportform.datastatics.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * @ClassNameSaticScheduleTask
 * @Description
 * @Author yck
 * @Date2020-10-20 9:41
 * @Version V1.0
 **/
@Configuration      //1.主要用于标记配置类，兼备Component的效果。
@EnableScheduling   // 2.开启定时任务
public class SaticScheduleTask {
    @Autowired
    private ReportService reportServiceImpl;


    @Autowired
    private GreenBodiesService greenBodiesService;
    //或直接指定时间间隔，例如：5秒
    //@Scheduled(fixedRate=10000)
    @Scheduled(cron = "0 0/5 * * * ?")
    private void configureTasks() throws Exception {
     Long startTime = System.currentTimeMillis();
        reportServiceImpl.asphaltData();
        reportServiceImpl.petroleumCokeData();
        reportServiceImpl.radarChartOfpetroleumCoke();
        reportServiceImpl.consumptionAnalysisOfCalcinedCoke();
        reportServiceImpl.categoryOfauxiliaryMaterials();
        reportServiceImpl.cookedBillet();
        reportServiceImpl.cookeBilletCurve();
        greenBodiesService.greenBodiesData();
       /* reportServiceImpl.stockDataUpdate();*/
        Long endTime = System.currentTimeMillis();
        Long tempTime = (endTime - startTime);
        System.out.println("定时任务花费时间："+
                (((tempTime/86400000)>0)?((tempTime/86400000)+"d"):"")+
                ((((tempTime/86400000)>0)||((tempTime%86400000/3600000)>0))?((tempTime%86400000/3600000)+"h"):(""))+
                ((((tempTime/3600000)>0)||((tempTime%3600000/60000)>0))?((tempTime%3600000/60000)+"m"):(""))+
                ((((tempTime/60000)>0)||((tempTime%60000/1000)>0))?((tempTime%60000/1000)+"s"):(""))+
                ((tempTime%1000)+"ms"));
    }

}
